package com.aoip.telemetry.telemetry.configureui.business.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 通用方法抽离
 *
 * @author chenbai
 * @version 1.0
 * @date 2022/3/9 14:46
 */
public class CommonMethod {

    /**
     * 将编码按照key分组，并将key值一样的value放入map种的list
     *
     * @author chenbai
     * @date 2022/3/9
     **/
    public static void collectIdToMap(String keyId, String valueId, Map<String, List<String>> map) {
        List<String> analysisIdList = map.get(keyId);
        if (analysisIdList == null || analysisIdList.size() < 1) {
            List<String> ids = new ArrayList<>();
            ids.add(valueId);
            map.put(keyId, ids);
        } else {
            analysisIdList.add(valueId);
        }
    }

    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        System.out.println(encoder.encode("admin123"));
    }
}
